package parserUML;


/**
 * 
 */
import java.io.Serializable;
import java.util.*;
/**
 * @author Guillaume Chapuis
 *
 */
public class MethodObject extends VarObject implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 2323295144438610381L;
	/**
	 * list of the object's parameters
	 */
	public ArrayList<ParamObject> params;
	
	public MethodObject(String sName,String returnType){
		super(sName, returnType);
		params = new ArrayList<ParamObject>();
	}
	
	public String toString(){
		String res="";
		if(!this.modifiers.isEmpty()){
			res = "(";
			for(String mod : modifiers){
				res+=mod+", ";
			}
			res = res.substring(0, res.length()-2)+") ";
		}
		res+=this.getName()+"(";
		boolean hasParam = false;
		for(ParamObject param : params){
			res+=param.toString()+", ";
			hasParam=true;
		}
		if (hasParam){
			res=res.substring(0, (res.length()-2));
		}
		res+=")";
			res+=" : "+this.getType();
		
		return res;
	}
}
